package com.sgb.kjwl.view.ui.adapter.machine;

import android.content.Context;
import android.widget.TextView;

import com.sgb.kjwl.BR;
import com.sgb.kjwl.R;
import com.sgb.kjwl.model.entity.MachineInEntity;
import com.swgk.core.recyclerview.adapter.BaseRecycleAdapter;
import com.swgk.core.recyclerview.adapter.ItemViewHolder;
import com.swgk.core.util.MDateUtil;

import java.util.List;

public class MachineInAdapter extends BaseRecycleAdapter<MachineInEntity> {

    private TextView contentView;
    private TextView priceView;
    private TextView timeView;

    public MachineInAdapter(Context context, List<MachineInEntity> datas) {
        super(context, R.layout.item_machine_in, datas);
    }

    @Override
    public void convert(ItemViewHolder holder, final MachineInEntity entity) {
        holder.setBinding(BR.viewModel, entity);
        contentView = holder.getItem().findViewById(R.id.content_view);
        priceView = holder.getItem().findViewById(R.id.price_view);
        timeView = holder.getItem().findViewById(R.id.time_view);
        contentView.setText(entity.getConstructionTime() + "天 | " + entity.getAreaName());
        if (entity.getPrice().equals("0.00")) {
            priceView.setText("面议");
        } else {
            priceView.setText(entity.getPrice() + entity.getPriceUnitName());
        }
        try {
            timeView.setText(MDateUtil.getDateDiff(entity.getTime()));
        } catch (NumberFormatException e) {

        }
    }
}
